function [dwi, gradient_info] = ReadDWI(dwi_pathname, gradient_pathname, n, w, h, d)

dwi = zeros(n, w, h, d);
fid = fopen(dwi_pathname, 'r');
for z = 1 : d
    for y = 1 : h
        for x = 1 : w
            dwi(:, x, y, z) = fread(fid, n, 'float');
        end
    end
end
fclose(fid);

gradient_info = zeros(n, 3);
fid = fopen(gradient_pathname, 'r');
for i = 1 : n
    gradient_info(i, :) = fscanf(fid, '%f', 3);
    b_value = fscanf(fid, '%f', 1);
end
fclose(fid);

end